package com.feihao.zhou.mapper;

import com.feihao.zhou.bean.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface SingleTableCRUD {

    //查询所有学生：单表

    @Select("select * from student")
    List<Student> selectAllStudent();


    //查询id为。。 或者age=..
    @Select("select * from Student where id = #{p1} or age=#{p2}")
    List<Student> selectStudentByIdOrAge(@Param("p1") Integer id, @Param("p2") Integer age);


    //根据id查询学生：
    @Select("select * from student where id = #{id}")
    Student selectStudentById(int i);


    //新增：：
    @Insert("insert into student values(#{id},#{name},#{age},#{cid})")
    Integer insertStudent(Student student);

    //修改：
    @Update("update student set name = #{p1},age=#{p2} where id = #{p3}")
    Integer updateStudent(@Param("p1") String name, @Param("p2") Integer age, @Param("p3") Integer id);

    //删除：

    @Delete("delete from student where id = #{id}")
    Integer deleteStudent(Integer id);
}
